<!--
 * @Author: wangwang 2723008256@qq.com
 * @Date: 2023-08-11 09:06:57
 * @LastEditors: 番茄炒蛋蛋 wzh15802755802@163.com
 * @LastEditTime: 2024-10-22 10:36:29
 * @FilePath: \jzjypc4.2\src\components\yuyueBox\yuyuebox.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="fubtj">
    <el-dialog
      :visible.sync="dialogVisible"
      :show-close="isClose"
      :close-on-click-modal="false"
      :before-close="handleClose"
      width="448px"
      top="30vh"
    >
      <div class="top">
        <img src="../../assets/img/ffzyb/fubtj.png" alt="" />
      </div>
      <div class="content">
        <p>
          当前内容为服务包付费资源，需要付费后才可以查看，
          您可以选择咨询客服或立即购买下方为您推荐的服务包：
        </p>
        <div class="goodsLists" :style="scrollBox">
            <div class="goods" :style="scrollStyle">
              <div class="list" v-for="item in goods_lists" :key="item.goods_id" @click="choseGood(item.goods_id,item.goodsweek_id)" :class="{choseGood:choseGoodId == item.goods_id}">
                <h4>{{item.goods_title}}</h4>
                <div class="price" v-show="item.type == 1">
                  <h5>￥</h5>
                  <span>{{item.bottom_price}}<a style="font-size:12px">起</a></span>
                </div>
                <div class="price" v-show="item.type != 1">
                  <h5>￥</h5>
                  <span>{{item.price}}</span>
                </div>
                <div class="tips" @click="goyuyue1(item.goods_id,item.goodsweek_id)">立即查看</div>
                <div class="tips2">限时特惠</div>
              </div>
          </div>
        </div>
        
        <div class="caozuo">
          <div class="zixun" @click="zixun">咨询</div>
          <div class="chakan" @click="goyuyue()">立即查看</div>
        </div>
        <div class="tishi">
         <span>* </span>购买成功后，当前资源可立即使用
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ["choseGoodId","goods_lists","caclose"],
  inject: ["reload"],
  data() {
    return {
      dialogVisible: true,
      goods_id:'',//选择的商品id
      isClose:false,//是否可以关闭
      goodsweek_id:'',//周id
      scrollStyle:{
        width:'',
      },
      scrollBox:{
        // overflowX: 'scroll',
      },
      arr:'',
    };
  },
  created(){
    console.log(this.goods_lists)
    this.isClose = this.caclose
    if(this.goods_lists.length <=2){
        this.scrollBox = {}
        this.scrollStyle.width = 'auto'
      }else{
        this.scrollBox = {overflowX: 'scroll',}
        let test = (156 * this.goods_lists.length) + 'px'
        this.scrollStyle.width = test
      }
      this.choseGood(this.goods_lists[0].goods_id,this.goods_lists[0].goodsweek_id)
  },
  mounted(){
    
    
  },
  watch:{
    goods_lists(e){
      // console.log(e,"ahdjkasjdhasjkdkashjkahashkdasjk")
      this.choseGood(e[0].goods_id,e[0].goodsweek_id)
      // this.scrollStyle.width =(186 * 4) + 'px'
      
      if(e.length <=2){
        this.scrollBox = {}
        this.scrollStyle.width = 'auto'
      }else{
        this.scrollBox = {overflowX: 'scroll',}
        let test = (156 * e.length) + 'px'
        this.scrollStyle.width = test
      }
      
    },
  },
  methods: {
    //单个资源页关闭弹窗
    handleClose(){
      this.$emit("closefwbtj");
    },
    //选择商品
    choseGood(goods_id,goodsweek_id){
      console.log(goods_id)
      this.goods_id = goods_id;
      this.goodsweek_id = goodsweek_id
      this.$emit("choseGood",goods_id,goodsweek_id);
    },
    //点击咨询，弹出客服1二维码弹窗
    zixun(){
      this.$emit("zixun");
    },
    goyuyue1(id,goodsweek_id){
      this.goods_id = id;
      this.goodsweek_id = goodsweek_id;
      this.$emit("goyuyue",this.goods_id,this.goodsweek_id);
    },
    //前往查看预约
    goyuyue(){
      this.$emit("goyuyue",this.goods_id,this.goodsweek_id);
    },
  },
};
</script>

<style lang="less" scoped>
.fubtj {
  /deep/.el-dialog__header {
    padding: 0;
  }
  /deep/.el-dialog {
    margin-top: 13vh !important;
    border-radius: 20px;
    background: #7a787800 !important;
    box-shadow: none;
  }
  /deep/.el-dialog__body {
    padding: 0;
  }
  /deep/.el-dialog__headerbtn .el-dialog__close {
    color: #fff !important;
  }
  /deep/.el-dialog__headerbtn {
    position: absolute;
    top: 0;
    right: 0 !important;
    z-index:100;
  }
  .top {
    img {
      position: relative;
      top: 4px;
    }
  }
  .content {
    background: #fff;
    overflow: hidden;
    border-radius: 0px 0px 10px 10px;
    p {
      margin: 20px auto;
      width: 390px;
      line-height: 24px;
    }
    .goodsLists{
      margin: 0 auto;
      width: 365px;
      // overflow-x: scroll;
      .goods {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 190px;
        .list {
          position: relative;
          display: flex;
          flex-direction: column;
          align-items: center;
          // justify-content: center;
          margin-left: 40px;
          width: 110px;
          height: 128px;
          border: 3px solid #ccc;
          border-radius: 10px;
          cursor: pointer;
          h4 {
            margin-top: 10px;
            width: 90px;
            text-align: center;
            font-weight: normal;
            line-height: 22px;
            font-size: 14px;
            color: #333;
          }
          .price {
            display: flex;
            margin-top: 8px;
            color: #08A579;
            h5 {
              position: relative;
              top: 10px;
              font-size: 16px;
            }
            span {
              font-size: 26px;
            }
          }
          .tips {
            position: absolute;
            bottom: -2px;
            right: -3px;
            width: 60px;
            height: 20px;
            text-align: center;
            line-height: 20px;
            font-size: 12px;
            background: #08A579;
            border-radius: 10px 4px 10px 4px;
            color: #fff;
            cursor: pointer;
          }
          .tips2 {
            position: absolute;
            top: -15px;
            left: -3px;
            width: 60px;
            height: 20px;
            text-align: center;
            line-height: 20px;
            font-size: 12px;
            background: #4a4848;
            border-radius: 10px 4px 10px 4px;
            color: #feedc1;
          }
        }
        .list:first-of-type {
          margin-left: 0px;
        }
        .choseGood{
          width: 140px;
          height: 160px;
          border: 3px solid #08a579;
          background: #E8FAF5;
          box-shadow: 0px 0px 30px 10px #E8FAF5;
          h4{
            margin-top: 20px;
            margin-bottom: 14px;
            color: #08A579;
          }
          .tips{
            background: #08A579;
          }
        }
      }
    }
    
    .caozuo{
      display: flex;
      justify-content: center;
      margin-top: 30px;
      .zixun,.chakan{
        width: 100px;
        height: 36px;
        text-align: center;
        line-height: 36px;
        font-size: 14px;
        border: 1px solid #08A579;
        border-radius: 4px;
        cursor: pointer;
        user-select: none;
      }
      .zixun,.chakan:active{
        opacity: 0.8;
      }
      .zixun{
        margin-right: 60px;
        color: #08A579;
      }
      .chakan{
        background: #08A579;
        color: #FFF;
      }
    }
    .tishi{
      margin: 15px 0 30px 0 ;
      text-align: center;
      font-size: 14px;
      color: #999999;
      span{
        color: #F05659;
      }
    }
  }
}
</style>